#include <stdio.h>
#include "mpi.h"
#include "dtypes.h" /* include for tests */

int main(int argc, char **argv)
{
    MPI_Datatype contig, vect;
    MPI_Aint ext, lb, ub;
    int size;
    
    MPI_Init(&argc, &argv);

    /**************************************
     * test of creating vector type with  * 
     * contiguous type                    *
     **************************************/

    MPI_Type_contiguous(2, MPI_INT, &contig);

    MPI_Type_vector(3, 2, 3, contig, &vect);

    fputs("Printing contiguous type (2 integers)\n", stdout);
    TEST_print_type(contig);

    /* additional tests */
    MPI_Type_size(contig, &size);
    MPI_Type_extent(contig, &ext);
    MPI_Type_lb(contig, &lb);
    MPI_Type_ub(contig, &ub);
    fputs("Results:\n", stdout);
    fprintf(stdout, "size: %d, extent: %d\nlb: %d, ub: %d\n", 
            size, ext, lb, ub);

    fputs("Printing vector type (3 blocks,\n", stdout);
    fputs("2 of previous type each, stride 3)\n", stdout);
    TEST_print_type(vect);

    /* additional tests */
    MPI_Type_size(vect, &size);
    MPI_Type_extent(vect, &ext);
    MPI_Type_lb(vect, &lb);
    MPI_Type_ub(vect, &ub);
    fputs("Results:\n", stderr);
    fprintf(stderr, "size: %d, extent: %d\nlb: %d, ub: %d\n", 
            size, ext, lb, ub);

    MPI_Finalize();
    
    return(0);
}

